const {logger, result} = require("../utils")
const {SYS_ERROR} = require("../enumeration/code")
module.exports = async (ctx, next) => {
  try {
    await next()
  } catch (error) {
    if (error.errorCode) {
      ctx.body = result(null, error.msg, error.code)
    } else {
      logger(error.stack).error()
      ctx.body = result(null, "系统异常", SYS_ERROR)
    }
  }
}
